<template>
  <div class="flex flex-col h-full">
    <!-- () => formRef.resetFields() -->
    <SearchContainer @search="store.getData" @reset="store.onReset">
      <a-form ref="formRef" class="form-style-flex" :model="store.searchData" :label-col="{ style: { width: '75px' } }">
        <a-form-item name="zjm">
          <a-input v-model:value="store.searchData.zjm" class="w-56" placeholder="床位号/姓名/助记码" allow-clear />
        </a-form-item>
        <a-form-item name="recordDate" class="ml-3">
          <SelectArea v-model:value="store.searchData.wardId" use-cache post-url :post-params="{ wardTypeCodes: ['QYLB001', 'QYLB002'] }" />
        </a-form-item>
        <a-form-item name="recordDate" class="ml-3">
          <div class="flex">
            <a-button type="primary" ghost @click="store.onClickDay('0')">前一天</a-button>
            <a-date-picker v-model:value="store.searchData.recordDate" value-format="YYYY-MM-DD" class="mx-2 w-32" />
            <a-button type="primary" ghost @click="store.onClickDay('1')">后一天</a-button>
          </div>
        </a-form-item>
      </a-form>
    </SearchContainer>
    <a-card class="mt-2 flex-1">
      <div class="flex items-center justify-between mb-2">
        <div class="float-left flex items-center">
          <a-radio-group v-model:value="store.tabActiveKey" button-style="solid" @change="store.getData">
            <a-radio-button :value="0">基本数据</a-radio-button>
            <a-radio-button :value="1">时点数据</a-radio-button>
          </a-radio-group>
          <div v-if="store.tabActiveKey === 1">
            <span class="mx-4">时间点</span>
            <a-radio-group v-if="recordHoursStyle === '0'" v-model:value="store.searchData.time" @change="store.getData">
              <a-radio :value="2">02</a-radio>
              <a-radio :value="6">06</a-radio>
              <a-radio :value="10">10</a-radio>
              <a-radio :value="14">14</a-radio>
              <a-radio :value="18">18</a-radio>
              <a-radio :value="22">22</a-radio>
            </a-radio-group>
            <a-radio-group v-if="recordHoursStyle === '1'" v-model:value="store.searchData.time" @change="store.getData">
              <a-radio :value="2">03</a-radio>
              <a-radio :value="6">07</a-radio>
              <a-radio :value="10">11</a-radio>
              <a-radio :value="14">15</a-radio>
              <a-radio :value="18">19</a-radio>
              <a-radio :value="22">23</a-radio>
            </a-radio-group>
          </div>
        </div>
        <div class="flex mb-2">
          <a-button class="mr-2" @click="store.onPrintRecord"><BaseIcon name="PrinterOutlined" />记录单</a-button>
          <a-button type="primary" class="mr-2" @click="store.onSaveAll()">保存</a-button>
          <a-button v-if="store.isAuditStatus" type="primary" class="mr-2" :disabled="!store.tableData.length" @click="store.onClickExamine(1)">审核</a-button>
          <a-button v-else type="primary" danger :disabled="!store.tableData.length" @click="store.onClickExamine(0)">撤销审核</a-button>
        </div>
      </div>
      <BasicData v-if="store.tabActiveKey === 0" />
      <TimePointData v-else />
    </a-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
// import { getSystemConfig } from '@/utils/systemConfig'
import SearchContainer from '@/components/SearchContainer'
import { getSystemConfig } from '@/utils/systemConfig'
import BasicData from './components/BasicData'
import TimePointData from './components/TimePointData'
import useStore from './store'

const store = useStore()
const formRef = ref(null)
const recordHoursStyle = ref('0')
onMounted(() => {
  //INP_TEMPERATURE_RECORD_STYLE 体温脉搏单的时点样式  0：通用26时点|1：安徽37时点
  recordHoursStyle.value = getSystemConfig('INP_TEMPERATURE_RECORD_STYLE')
  setTimeout(() => {
    store.getData()
  })
})
</script>
<style lang="less" scoped></style>
